<?php
	include("../include/init.php");//将配置文件全部加载进来
	include("../include/check_login.php");//登录

	$insert = new sql_class("order");
	$product = new sql_class("product");
	$user = new sql_class("user");

	$pro_list = $product->select()->getAll();
	$user_list = $user->select()->getAll();

	$order_id = isset($_GET['order_id']) ? $_GET['order_id'] : 0;
	if(!$order_id){
		show_msg("请重新选择","order_list.php");
		exit;
	}	
	$where = "order_id = $order_id";
	$order_one = $insert->select($where)->getOne();


	if($_POST){
		$data = array(
					"order_sn"=>$_POST['order_sn'],
					"order_price"=>$_POST['order_price'],
					"order_time"=>strtotime($_POST['order_time']),
					"order_username"=>$_POST['order_username'],
					"order_phone"=>$_POST['order_phone'],
					"order_number"=>$_POST['order_number'],
					"order_date"=>strtotime($_POST['order_date']),
					"product_id"=>$_POST['product_id'],
					"user_id"=>$_POST['user_id'],
				);
		$where = "order_id = $order_id";
		$insert_id = $insert->update($data,$where);
		if($insert_id){
			show_msg("更新订单成功","order_list.php");
			exit;
		}else{
			show_msg("更新订单失败","order_edit.php?order_id = $order_id");
			exit;
		}
	}
	
	$smarty->assign("order_one",$order_one);
	$smarty->assign("user_list",$user_list);
	$smarty->assign("pro_list",$pro_list);
	$smarty->display("admin/order_edit.html");//连接index.html



?>